@model AssignOrganizationViewModel
@{
    ViewData["Title"] = "分配组织用户";
}

<div class="card">
    <div class="card-header">
        <h3 class="card-title">分配组织用户 - @Model.OrganizationName</h3>
    </div>
    <div class="card-body">
        @if (TempData["ErrorMessage"] != null)
        {
            <div class="alert alert-danger">@TempData["ErrorMessage"]</div>
        }
        @if (TempData["SuccessMessage"] != null)
        {
            <div class="alert alert-success">@TempData["SuccessMessage"]</div>
        }

        <form asp-action="AssignOrganization" method="post">
            <input type="hidden" asp-for="OrganizationId" />
            <input type="hidden" asp-for="OrganizationName" />

            <div class="form-group">
                <table class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th>选择</th>
                            <th>用户姓名</th>
                        </tr>
                    </thead>
                    <tbody>
                        @for (var i = 0; i < Model.AvailableUsers.Count; i++)
                        {
                            <tr>
                                <td>
                                    <input type="hidden" asp-for="@Model.AvailableUsers[i].UserId" />
                                    <input type="hidden" asp-for="@Model.AvailableUsers[i].UserName" />
                                    <input type="checkbox" asp-for="@Model.AvailableUsers[i].IsSelected" />
                                </td>
                                <td>@Model.AvailableUsers[i].UserName</td>
                            </tr>
                        }
                    </tbody>
                </table>
            </div>

            <div class="form-group">
                <button type="submit" class="btn btn-primary">保存</button>
                <a asp-controller="Organization" asp-action="Index" class="btn btn-secondary">返回</a>
            </div>
        </form>
    </div>
</div>
